<!DOCTYPE html>
<html>
<head lang="en">
    <meta charset="UTF-8">
    <title></title>
    <style>
        rect {
            fill: transparent;
            stroke: black;
            stroke-dasharray: 10;
        }
        .css {
            stroke-dashoffset: 60;
            animation: ani 1s linear infinite;
        }
        @keyframes ani {
            to {
                stroke-dashoffset: 0;
            }
        }
    </style>
</head>
<body>
<svg>
    <rect class='css' x='0' y='0' width='100' height='100' />
    <rect class='js' x='130' y='0' width='100' height='100' />
</svg>
</body>
</html>

<script>
    var path = document.querySelector('.js'),
            offset = 60;

    var offsetMe = function() {
        if (offset < 0) offset = 60;
        path.style.strokeDashoffset = offset;
        offset--;

        requestAnimationFrame(offsetMe);
    }

    offsetMe();
</script>